package com.estate.business.impl;

import java.util.List;

import com.estate.business.ContractService;
import com.estate.dao.ContractDao;
import com.estate.dao.ContractFileDao;
import com.estate.vo.Vo;
import com.estate.vo.impl.ContractVo;

public class ContractServiceImpl implements ContractService{
	
	private ContractDao contractDao;
	private ContractFileDao contractFileDao;

	public ContractDao getContractDao() {
		return contractDao;
	}

	public void setContractDao(ContractDao contractDao) {
		this.contractDao = contractDao;
	}
	
	public boolean addContract(ContractVo contract) {
		boolean result = false;
		result = contractDao.addVo(contract);
		return result;
	}

	public List<Vo> getAllContract() {
		List<Vo> contractList = contractDao.findAll();
		return contractList;
	}

	public Vo getContractByPk(Integer pk){
		Vo contract = contractDao.findByPK(pk);
		return contract;
		
	}

	public boolean updateContractVo(ContractVo contract) {
		boolean result = false;
		result = this.getContractDao().updateVo(contract);
		return result;
	}

	public boolean deleteContractVo(ContractVo contract) {
		boolean result = false;
		contractFileDao.deleteByContractId(contract.getId());
		result = this.getContractDao().deleteVo(contract);
		return result;
	}

	public void setContractFileDao(ContractFileDao contractFileDao) {
		this.contractFileDao = contractFileDao;
	}

	public ContractFileDao getContractFileDao() {
		return contractFileDao;
	}

	
	

}
